﻿//********************************************************************************//
//创建日期：<创建日期，2016-09-02>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：水资源水价批量调整
//********************************************************************************//
using BLL;
using BLL.Access;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.JiChuXX
{
    public partial class ShuiZiYSJPLTZ : BasePage
    {
       
        
        #region 属性

        /// <summary>
        /// 保存结果集
        /// </summary>
        private DataTable dtSource
        {
            get
            {
                return ViewState["dtSource"] as DataTable;
            }
            set
            {
                ViewState["dtSource"] = value;
            }
        }

        #endregion

        #region 变量


        /// <summary>
        /// 水资源水价信息bll
        /// </summary>
        QS_JX_SHUIZIYSJXXBLL _QS_JX_SHUIZIYSJXXBLL = new QS_JX_SHUIZIYSJXXBLL();

        /// <summary>
        /// 操作日志BLL
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();

        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                LoadData();
            }
        }

       /// <summary>
       /// 响应前台回调
       /// </summary>
       /// <param name="source"></param>
       /// <param name="e"></param>
        //protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        //{
        //    if (e.Parameter == "adjust")
        //    {
        //        string msg = "";
        //        decimal oldSJ = Convert.ToDecimal(this.hdCollection.Get("oldsj"));
        //        decimal newSJ = Convert.ToDecimal(this.hdCollection.Get("newsj"));
        //        DataTable dtxx = _SpHelper.P_QSJX_SHUIZIYSJ(2, oldSJ, newSJ).Tables[0];
        //        msg = dtxx.Rows[0][0].ToString();
        //        e.Result = e.Parameter + "|0|" + msg;
        //    }
        //    else if (e.Parameter == "reload")
        //    {
        //        LoadData();
        //    }
           
        //}

        /// <summary>
        /// 放弃调整
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnFangQi_Click(object sender, EventArgs e)
        {
            txtXinShuiJ.Text = "";
        }

       
        #endregion

        #region 方法

        /// <summary>
        /// 数据加载
        /// </summary>
        private void LoadData()
        {
            cmbYuanShuiJ.Items.Clear();
            this.dtSource = _SpHelper.P_QSJX_SHUIZIYSJ(1,null,null).Tables[0];
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                cmbYuanShuiJ.Items.Add(Convert.ToDecimal(dtSource.Rows[i]["N_SHUIJIA"]).ToString("0.00"), dtSource.Rows[i]["N_SHUIJIA"]);
            }
            cmbYuanShuiJ.SelectedIndex = 0;
        }

        #endregion        

        protected void btnTiaoZheng_Click(object sender, EventArgs e)
        {
            var oldsj = cmbYuanShuiJ.Text;
            var newsj = txtXinShuiJ.Text;
            decimal oldSJ = Convert.ToDecimal(oldsj);
            decimal newSJ = Convert.ToDecimal(newsj);
            DataTable dtxx = _SpHelper.P_QSJX_SHUIZIYSJ(2, oldSJ, newSJ).Tables[0];
            if (dtxx.Rows.Count > 0)
            {
                PageTools.AlertMsg(this, "调整成功");
                LoadData();
            }
        }
    }
}